//  Copyright 2009-2010 Aurora Feint, Inc.
// 
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//  
//  	http://www.apache.org/licenses/LICENSE-2.0
//  	
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.



#import "OFResource.h"

@class OFService;
@class OFRequestHandle;
class OFHttpService;
class OFImageViewHttpServiceObserver;

@protocol OFInviteDefinitionDelegate;


//////////////////////////////////////////////////////////////////////////////////////////
///  The public interface to OFInviteDefinition allows you to get Invite Definitions that
///  are defined on the developer dashboard.
//////////////////////////////////////////////////////////////////////////////////////////
@interface OFInviteDefinition : OFResource<OFCallbackable>
{
	@package
	// These get copied into an invite (modulo string interpolation) at the time the invite is sent.
	NSString* clientApplicationName;		
	NSString* clientApplicationID;			
	NSString* inviteIdentifier;				
	NSString* senderParameter;				
	NSString* receiverParameter;			
	NSString* inviteIconURL;				
	NSString* developerMessage;				
	NSString* receiverNotification;			
	NSString* senderNotification;			

	// These don't get copied, because they're only used at send time.
	NSString* senderIncentiveText;			
	NSString* suggestedSenderMessage;
	
	OFPointer<OFHttpService> mHttpService;
	OFPointer<OFImageViewHttpServiceObserver> mHttpServiceObserver;
}

//////////////////////////////////////////////////////////////////////////////////////////
/// Set a delegate for all OFInviteDefinition related actions. Must adopt the 
/// OFInviteDefinitionDelegate protocol.
///
/// @note Defaults to nil. Weak reference
//////////////////////////////////////////////////////////////////////////////////////////
+ (void)setDelegate:(id<OFInviteDefinitionDelegate>)delegate;

//////////////////////////////////////////////////////////////////////////////////////////
/// Get the Primary Invite definition as defined on the developer dashboard
///
/// @return OFRequestHandle for the server request.  Use this to cancel the request
///
/// @note Invokes		- (void)didGetPrimaryInviteDefinition:(OFInviteDefinition*)definition on success and
///						- (void)didFailGetPrimaryInviteDefinition on failure.
//////////////////////////////////////////////////////////////////////////////////////////
+ (OFRequestHandle*)getPrimaryInviteDefinition;

//////////////////////////////////////////////////////////////////////////////////////////
/// Get an invite Definition by its invite id defined on the developer dashboard.
///
/// @return OFRequestHandle for the server request.  Use this to cancel the request
///
/// @note Invokes		- (void)didGetInviteDefinition:(OFInviteDefinition*)definition on success and
///						- (void)didFailGetInviteDefinition on failure
//////////////////////////////////////////////////////////////////////////////////////////
+ (OFRequestHandle*)getInviteDefinition:(NSString*)inviteId;

//////////////////////////////////////////////////////////////////////////////////////////
/// Get the Invite Icon associated with this invite
///
/// @return OFRequestHandle for the server request.  Use this to cancel the request
///
/// @note Invokes		- (void)didGetInviteIcon:(UIImage*)image OFInvite:(OFInvite*)invite; on success and
///						- (void)didFailGetInviteIconOFInvite:(OFInvite*)invite; on failure
//////////////////////////////////////////////////////////////////////////////////////////
- (OFRequestHandle*)getInviteIcon;

//////////////////////////////////////////////////////////////////////////////////////////
/// Name of the application associated with this invite definition.
//////////////////////////////////////////////////////////////////////////////////////////
@property (nonatomic, readonly) NSString* clientApplicationName;

//////////////////////////////////////////////////////////////////////////////////////////
/// The Application ID that this invite definition belongs to
//////////////////////////////////////////////////////////////////////////////////////////
@property (nonatomic, readonly) NSString* clientApplicationID;

//////////////////////////////////////////////////////////////////////////////////////////
/// Identifier as input on the developer dashboard
//////////////////////////////////////////////////////////////////////////////////////////
@property (nonatomic, readonly) NSString* inviteIdentifier;

//////////////////////////////////////////////////////////////////////////////////////////
/// Sender Parameter as defined in the developer dashboard
/// @note Only for Premium Members
//////////////////////////////////////////////////////////////////////////////////////////
@property (nonatomic, readonly) NSString* senderParameter;

//////////////////////////////////////////////////////////////////////////////////////////
/// Receiver Parameter as defined in the developer dashboard
/// @note Only for Premium Members
//////////////////////////////////////////////////////////////////////////////////////////
@property (nonatomic, readonly) NSString* receiverParameter;

//////////////////////////////////////////////////////////////////////////////////////////
/// The user-uneditable string for this invite definition as seen on the developer dashboard
//////////////////////////////////////////////////////////////////////////////////////////
@property (nonatomic, readonly) NSString* developerMessage;

//////////////////////////////////////////////////////////////////////////////////////////
/// Receiver Notification as seen on the developer dashboard.
//////////////////////////////////////////////////////////////////////////////////////////
@property (nonatomic, readonly) NSString* receiverNotification;

//////////////////////////////////////////////////////////////////////////////////////////
/// Sender Notification as seen on the developer dashboard.
//////////////////////////////////////////////////////////////////////////////////////////
@property (nonatomic, readonly) NSString* senderNotification;

//////////////////////////////////////////////////////////////////////////////////////////
/// The "Call to Action" field input on the developer dashboard.
//////////////////////////////////////////////////////////////////////////////////////////
@property (nonatomic, readonly) NSString* senderIncentiveText;

//////////////////////////////////////////////////////////////////////////////////////////
/// The suggested, user editable message as seen on the developer dashboard.
//////////////////////////////////////////////////////////////////////////////////////////
@property (nonatomic, readonly) NSString* suggestedSenderMessage;

//////////////////////////////////////////////////////////////////////////////////////////
/// @internal
//////////////////////////////////////////////////////////////////////////////////////////
+ (NSString*)getResourceName;
@property (nonatomic, readonly) NSString* inviteIconURL;

@end

//////////////////////////////////////////////////////////////////////////////////////////
/// Adopt the OFInviteDefinitionDelegate Protocol to receive information regarding OFInviteDefinition.  
/// You must call OFInviteDefinition's +(void)setDelegate: method to receive information
//////////////////////////////////////////////////////////////////////////////////////////
@protocol OFInviteDefinitionDelegate
@optional
//////////////////////////////////////////////////////////////////////////////////////////
/// Invoked when getPrimaryInviteDefinition successfully completes
///
/// @param definition		The requested primary definition
//////////////////////////////////////////////////////////////////////////////////////////
- (void)didGetPrimaryInviteDefinition:(OFInviteDefinition*)definition;

//////////////////////////////////////////////////////////////////////////////////////////
/// Invoked when getPrimaryInviteDefinition fails.
//////////////////////////////////////////////////////////////////////////////////////////
- (void)didFailGetPrimaryInviteDefinition;

//////////////////////////////////////////////////////////////////////////////////////////
/// Invoked when getInviteDefinition: successfully completes
///
/// @param definition		The requested definition
//////////////////////////////////////////////////////////////////////////////////////////
- (void)didGetInviteDefinition:(OFInviteDefinition*)definition;

//////////////////////////////////////////////////////////////////////////////////////////
/// Invoked when getInviteDefinition: fails.
//////////////////////////////////////////////////////////////////////////////////////////
- (void)didFailGetInviteDefinition;

//////////////////////////////////////////////////////////////////////////////////////////
/// Invoked when getInviteIcon successfully completes
///
/// @param image			The image requested
/// @param inviteDef		The invite definition the image belongs to.
//////////////////////////////////////////////////////////////////////////////////////////
- (void)didGetInviteIcon:(UIImage*)image OFInviteDefinition:(OFInviteDefinition*)inviteDef;

//////////////////////////////////////////////////////////////////////////////////////////
/// Invoked when getInviteIcon fails
///
/// @param inviteDef		The OFInviteDefinition for which the image was requested.
//////////////////////////////////////////////////////////////////////////////////////////
- (void)didFailGetInviteIconOFInviteDefinition:(OFInviteDefinition*)inviteDef;

@end









